/*
 * Created on 29/06/2006
 *
 */
package ar.com.cubika.trainees.view;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ar.com.cubika.trainees.bean.transportes.Chofer;
import ar.com.cubika.trainees.bean.transportes.Empresa;
import ar.com.cubika.trainees.dao.VehiculoDAO;

public class EliminarVehiculoServlet extends HttpServlet {
    
    

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	
    	String patente = request.getParameter("vehiculo");
   
    	int finalPantente;
    	finalPantente = patente.indexOf(' ');
    	Empresa empresa = Empresa.getInstance();
    	patente = patente.substring(0, finalPantente);
  
    	empresa.deleteVehiculo(patente);
    	VehiculoDAO.getInstance().deleteVehiculo(patente);
        request.getRequestDispatcher("/viewEmpresa").forward(
                request, response);
        
    }
    
    

}